#include <iostream>

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	int a[n];
	for(int i = 0;i < n;i++){
		int n2;
		cin >> n2;
		a[i] = n2;
	}
	for(int i = 0;i < m;i++){
		int n3;
		cin >> n3;
		cout << a[(n3-1)]  << ' ';
	} 
} 
